<template>
 <div>
   <h1 align="center">劳务人员管理系统</h1>
   <div>
     <!-- 1设置容器 -->
     <div id="chart" style="width: 600px; height: 400px;"></div>
   </div>
 </div>
</template>

<script>
import { mapGetters } from 'vuex'
import * as echarts from 'echarts'
import axios from "axios";
import {getContractTypeNum} from "@/api/contractManage/contractSigning";

export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  mounted() {
    this.initChart()
  },
  methods: {
    // 动态获取数据
    initChart(){

      // 发送异步请求获取数据
      getContractTypeNum().then(res=>{
        const chart = echarts.init(document.getElementById('chart'))
        chart.setOption({
          title:{
            text:"合同类型数量展示"
          },
          tooltip:{
            trigger:"axis",
          },
          legend:{
            data:["合同类型"]
          },
          // x轴数据
          xAxis:{
            type:"category",
            data:res.data.xType
          },
          // y轴数据
          yAxis:{
            type:"value",
          },
          series:[
            {
              name:"合同类型",
              type:"bar",
              data:res.data.yValue,
            },
          ]
        })
      })
      //chart.setOption(option)
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
